package com.yckj.demo.dongao.controller;

import com.yckj.demo.dongao.entity.Lawyer;
import com.yckj.demo.dongao.service.LawyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.xml.ws.RequestWrapper;
import java.util.List;

/**
 * 律师控制器
 * @auther wanghan
 * @version 1.0
 */
@Controller
public class LawyerController {
    @Autowired
    LawyerService lawyerService;
    @RequestMapping("/del")
    public String delLawyer(int lawyerid){
        lawyerService.removeLawyer(lawyerid);
        return "../static/success";
    }
    @RequestMapping("/show")
    public String showLawyer(Model model){
        List<Lawyer> lawyerList = lawyerService.findLawyer();
        //传递到网页上把lawyerList
        model.addAttribute("lawyerList",lawyerList);
        //displayLawyer代表displayLawyer.html
        return "../sattic/displayLawyer";
    }
    @RequestMapping("/addLawyer")


    public String addLawyer(Lawyer lawyer){
        lawyerService.addLawyer(lawyer);
        //代表网页success.html
        return "../static/success.html";
    }

}
